/*
 * ImageButton.h
 *
 *  Created on: 2012-10-20
 *      Author: yangentao@gmail.com
 */

#ifndef IMAGEBUTTON_H_
#define IMAGEBUTTON_H_
#include "Panel.h"

#define TRANSPARENT_COLOR_NONE	(-1)

class ImageButtonParam {
public:
	String imageNormal;
	String imageMouseEnter;
	String imageMouseDown;
};

enum ButtonStatus {
	bsNormal,
	bsMouseEnter,
	bsMouseDown
};

class AtlImage;
class ImageButton: public Panel {
	typedef Panel Super;
public:
	ImageButton();
	virtual ~ImageButton();
public:
	bool create(HWND parent, Rect rect);
public:
	bool loadImage(ImageButtonParam images);
	bool setImageNormal(String imageFile);
	bool setImageMouseEnter(String imageFile);
	bool setImageMouseDown(String imageFile);
	int getImageWidth();
	int getImageHeight();
	void setTransparentColor(LONG color);
public:
	void onPaint(HWND, HDC, PAINTSTRUCT*);
	bool onMouseEnter(const MouseEvent& me);
	bool onMouseLeave(const MouseEvent& me);
	bool onLeftButtonDown(const MouseEvent& me);
	bool onLeftButtonUp(const MouseEvent& me);

private:
	boost::shared_ptr<AtlImage> imageNormal;
	boost::shared_ptr<AtlImage> imageMouseEnter;
	boost::shared_ptr<AtlImage> imageMouseDown;
//	ATL::CImage imageBorder;

	ButtonStatus status;
	LONG transparentColor;
	WindowListenerAdapter InnerEvents;
};

#endif /* IMAGEBUTTON_H_ */
